package type.pets;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date 2021/4/29 3:25 下午
 * @Author dengxin
 */
public class ForNameCreator extends PetsCreator {

    private static List<Class<? extends Pet>> types = new ArrayList<>();

    private static String[] typeName = {"type.pets.Cat", "type.pets.Dog", "type.pets.Mouse", "type.pets.Snake"};

    private static void load() {
        for (String type: typeName
             ) {
            try {
                types.add((Class<? extends Pet>) Class.forName(type));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                System.out.println("Type for name Error");
            }
        }
    }

    static {
        load();
    }

    @Override
    List<Class<? extends Pet>> types() {
        return types;
    }
}
